package com.hbgc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hbgc.mapper.TbTypeMapper;
import com.hbgc.pojo.TbType;
import com.hbgc.service.IVideoTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class VideoTypeServiceImpl implements IVideoTypeService {


    @Autowired
    private TbTypeMapper tbtypeMapper;


    @Override
    public PageInfo queryTbTypeByPage(int pageNow, int pageSize, String typename) {
        //设置分页的条件,分页功能必须要启用分页插件才行
        PageHelper.startPage(pageNow,pageSize);
        //条件查询
        List<TbType> tbTypes = tbtypeMapper.selectAllByTypenameList(typename);
        //把查询的结果使用pageinfo进行封装
        PageInfo pageInfo=new PageInfo(tbTypes);
        return pageInfo;
    }

    @Override
    public List queryTbTypeByPid(boolean isAll) {
        return tbtypeMapper.selectAllByPidList(isAll);
    }

    @Override
    public boolean saveTbType(TbType tbtype) {
        return tbtypeMapper.insert(tbtype)>0?true:false;
    }

    @Override
    public boolean updateTbTypeById(TbType tbType) {
        return tbtypeMapper.updateByPrimaryKey(tbType)>0?true:false;
    }

    @Override
    public boolean deleteTbTypeById(Long typeid) {
        return tbtypeMapper.deleteByPrimaryKey(typeid)>0?true:false;
    }

    @Override
    public TbType getTbTypeById(Long typeid) {
       return tbtypeMapper.selectByPrimaryKey(typeid);
    }
}
